package actionmodel.factory_pattern.SimpleDemo;

/**
 * @Author yangjin
 * @Description
 * @Date 2021/12/9/17:32
 **/
public class FruitFactory {

    public static String APPLE = "APPLE";
    public static String BANANA = "BANANA";
    public static String WATERMELON = "WATERMELON";

    public Fruit buyFruit(String fruitName){
        if (fruitName == null){
            return null;
        }
        if ("APPLE".equals(fruitName)){
            return new Apple();
        }else if ("BANANA".equals(fruitName)){
            return new Banana();
        }else if ("WATERMELON".endsWith(fruitName)){
            return new Watermelon();
        }else {
            return null;
        }
    }
}
